<template>
  <a :href="detailUrl">
    <div class='book-card'>
      <div class='thumb'>
        <img @click.stop='preview' :src='book.image' class='image' mode='aspectFit'>
      </div>
      <div class="detail">
        <div class="row title text-primary">
          <div class="right">
            {{book.rate}}<Rate :value='book.rate'></Rate>
          </div>
          <div class="left">
            {{book.title}}
          </div>
        </div>
        <div class="row middle">
          <div class="right">
            浏览量：{{book.count}}
          </div>
          <div class="left">
            {{book.author}}
          </div>
        </div>
        <div class="row">
          <div class="right">
            {{book.user_info.nickName}}
          </div>
          <div class="left">
            {{book.publisher}}
          </div>
        </div>
      </div>
    </div>
  </a>
</template>
<script>
import Rate from '@/components/Rate'
export default {
  props: ['book'],
  components: {
    Rate
  },
  computed: {
    detailUrl () {
      return '/pages/detail/main?id=' + this.book.id
    }
  },
  methods: {
    preview () {
      wx.previewImage({
        current: this.book.image,
        urls: [this.book.image]
      })
    }
  }
}
</script>
<style lang="scss">
.book-card{
  padding: 5px;
  overflow:hidden;
  margin-top: 5px;
  margin-bottom: 5px;
  font-size:14px;
  .thumb {
    width: 90px;
    height: 90px;
    float: left;
    margin: 0 auto;
    img{
      width: 100%;
      max-height: 100%;
    }
  }
  .detail{
    margin-left: 100px;
    .row{
      line-height: 20px;
      margin-bottom: 3px;
      .right{
        float:right;
      }
      .left{
        overflow:hidden;
        text-overflow:ellipsis;
        white-space:nowrap;
      }
      &.middle{
        margin: 10px 0 5px 0;
      }
      &.title{
        .left{
          font-size: 16px;
        }
      }
    }

  }
}
</style>
